import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/login'
import performanceGraph from "@/views/performanceGraph";
import baseInfo from "@/views/baseInfo";
Vue.use(VueRouter)
import info from "@/views/info";
import spquality from "@/views/spquality";
import touch from "@/views/touch";
import stability from "@/views/stability";
import fluency from "@/views/fluency";
import SideBar2 from "@/components/SideBar2";
import performanceLatestTime from "../views/performanceLatestTime";
import userManager from "../views/userManager";
import serverInfo from "../views/serverInfo";
import systemSetting from "../views/systemSetting";
import cloudPhoneManager from "../views/cloudPhoneManager";
import roleManager from "../views/roleManager";
import systemFunction from "../views/systemFunction";
import addScene from "../views/addScene"
import uploadPage from "../views/uploadPage";
import cloudPhoneBaseInfo from "../views/cloudPhoneBaseInfo"
import titleComponet from "@/components/titleComponet";
const routes = [
  {
    path: '/',
    name: 'login',
    component: Login
  },
  {
    path: '/titleComponet',
    name: 'titleComponet',
    component: titleComponet
  },
  {
    path: '/baseInfo',
    name: 'baseInfo',
    component: SideBar2,
    children:[
      {
        path: '/serverInfo',
        name: 'serverInfo',
        component: serverInfo
      },
      {
        path: '/baseInfo',
        name: 'baseInfo',
        component: baseInfo,
      },
      {
        path: '/performanceGraph',
        name: 'performanceGraph',
        component: performanceGraph,
      },
      {
        path: '/performanceLatestTime',
        name: 'performanceLatestTime',
        component: performanceLatestTime,
      },
      {
        path: '/addScene',
        name: 'addScene',
        component: addScene,
      },
      {
        path: '/userManager',
        name: 'userManager',
        component: userManager
      },
      {
        path: '/roleManager',
        name: 'roleManager',
        component: roleManager
      },
      {
        path: '/systemFunction',
        name: 'systemFunction',
        component: systemFunction
      },
      {
        path: '/cloudPhoneManager',
        name: 'cloudPhoneManager',
        component: cloudPhoneManager
      },
      {
        path:'/cloudPhoneBaseInfo',
        name: 'cloudPhoneBaseInfo',
        component: cloudPhoneBaseInfo
      },
    ]
  },
  {
    path: '/info',
    name: 'HelloWorld',
    component: SideBar2,
    children:[
      {
        path: '/info',
        name: 'info',
        component: info,
      },
      {
        path: '/fluency',
        name: 'fluency',
        component: fluency,
      },
      {
        path: '/stability',
        name: 'stability',
        component: stability,
      },
      {
        path: '/touch',
        name: 'touch',
        component: touch,
      },
      {
        path: '/spquality',
        name: 'spquality',
        component: spquality,
      },

      {
        path: '/systemSetting',
        name: 'systemSetting',
        component: systemSetting
      },
    {
        path: '/uploadPage',
        name: 'uploadPage',
        component: uploadPage
    }
    ]
  }
]
const router = new VueRouter({
  routes
})
router.beforeEach((to,from,next)=> {
  if (to.path === '/') {
    next();
  } else {
    let token = localStorage.getItem("Authorization");
    if (token === 'null' || token === '') {
      next('/')
    } else {
      next();
    }
  }
})
export default router
